1. Field of the Invention
The present invention generally relates to electronic data processing. More particularly, the invention relates to methods, systems and computer applications for data processing, including data locking.
2. Background Information
A database management system is usually equipped with a special lock mechanism that synchronizes access to data on the database. The purpose of the lock mechanism is to prevent two transactions from changing the same data on the database simultaneously.
Locks may be defined generically as “lock objects”. A lock entry is a specific instance of a lock object and locks a certain database object, such as a correction or a table entry or a file or a whole table.
Locks are usually set and deleted automatically when user programs access a data object and release it again.
When interactive transactions are programmed, locks may be set and released by calling specific function modules.
The tables in which data records should be locked with a lock entry are defined in a lock object together with their key fields. When tables are selected, one table (the primary table) is first selected. Further tables (secondary tables) can also be added using foreign key relationships.
The lock argument of a table in the lock object may consist of the key fields of the table. The lock argument fields of a lock object may be used as input parameters in the function modules for setting and removing locks generated from the lock object definition. When these function modules are called, the table entries to be locked or unlocked are specified by defining certain values in these fields. These values can also be generic or wildcards. The lock argument fields therefore define which subset of the table entries should be locked.
A simple case of a lock object consists of exactly one table and the lock argument of the table is the primary key of this table. Several tables can also be included in a lock object. A lock entry, therefore, can lock an entire logical object, and not only a record of a table. Such a logical object can be, for example, a document comprising an entry in a header table and N entries in a position table.
Furthermore, a lock mode may be assigned for each table in the lock object. A lock mode may define how other users can access a locked record of the table.
The lock mode controls whether several users can access data records at the same time. The lock mode can be assigned separately for each table in the lock object. When the lock is set, the corresponding lock entry is stored in the lock table of the system for each table.
Access by more than one user can be synchronized in the following ways:
Exclusive Lock: The locked data can only be displayed or edited by a single user. A request for another exclusive lock or for a shared lock is rejected.
Shared Lock: More than one user can access the locked data at the same time in display mode. A request for another shared lock is accepted, even if it comes from another user. An exclusive lock is rejected.
Exclusive But Not Cumulative: Exclusive locks can be requested several times from the same transaction and processed successively. In contrast, exclusive but not cumulative locks can be called only once from the same transaction. All other lock requests are rejected.
It is possible to synchronize access by several programs to the same data with a logical lock mechanism having two main functions: (i) a program can tell other programs which data records it is just reading or changing; and (ii) a program can prevent itself from reading data that is just being changed by another program.
Data records of a table to be locked may also be defined by a logical condition. When a lock is set, this logical condition is entered in a lock table. This entry is retained until it is removed by the program or the program comes to an end. All of the locks set by a program are thus removed at the end of the program.
When accessing data records, the records just being edited by other programs may be identified by the entry in the lock table. Such an entry for the lock may define a number of fully specified key fields. That is, either a value is passed for the key field or this field is locked generically by means of a wildcard.
In a multi-user system environment, as is frequently the case in enterprise business software and computer systems, data that is being processed by one user has to be locked, so that another user can not change it at the same time. This is essential to avoid data inconsistencies.
Usually, the data is locked via the key of the processed data (e.g., document number, cost center ID). However, business transactions that process a lot of data at the same time (e.g., the costing of a car with several thousand components, or the evaluation of a value flow net between many cost centers, activities and cost objects) can not lock every single piece of data via its key, since the number of locks that can be set is restricted due to limited hardware resources. For instance, a reasonable number of locks per transaction may be around 50 for larger multi-user systems. Anything more could harm the performance of the system. This is especially true, if several hundreds or thousands of users work at the same time setting locks in the system.
Thus, as stated above, mass transactions can not lock every single piece of data (e.g., every product number or every cost center ID). Instead, wildcards can be used in a lock entry so that it affects several single keys and many pieces of data can be locked via one entry. By way of example, U.S. Pat. No. 6,047,283 discloses a lock mechanism, in which a dynamic lock table is used for managing the collision of lock requests of several users accessing a database, for instance, by means of wildcards.
However, wildcards have to be used with care. Otherwise, too much data will be locked and other users will not be able to continue with their tasks, since they can't access needed data. For example, during the calculation of a product with 100 sub-products, one can not lock all products by only having a wildcard in the lock entry for product. Otherwise, a second user could not run a costing of an independent product.
Thus, there is a need for methods, systems and software applications that provide an efficient solution to at least part of the problems described above. Moreover, it is desirable to provide a method, system or software application having a mechanism for using wildcards in data locking more efficiently.
The above description is based on the knowledge of the present inventors and not necessarily that known in the art.